package com.zhou.app.favourite.service.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zhou.app.favourite.entity.FavAddress;
import com.zhou.app.favourite.mapper.FavAddressMapper;
import com.zhou.app.favourite.model.ao.FavAddressAo;
import com.zhou.app.favourite.service.service.IFavAddressService;
import com.zhou.common.lib.util.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.validation.Valid;

/**
 * <p>
 * 收藏地址 服务实现类
 * </p>
 *
 * @author zxf
 * @since 2023-04-15
 */
@Service
public class FavAddressServiceImpl extends ServiceImpl<FavAddressMapper, FavAddress> implements IFavAddressService {

    @Autowired
    private FavIconServiceImpl favIconService;

    @Override
    public void save(@Valid FavAddressAo addressAo) {
        FavAddress favAddress = new FavAddress();
        BeanUtils.copyBeanProp(favAddress, addressAo);
        save(favAddress);
        favIconService.addIcon(addressAo.getAddress());
    }
}
